local yingba = fk.CreateSkill {

  name = "joy__yingba",

  tags = {  },

}



yingba:addEffect("active", {
  name = "joy__yingba",
  anim_type = "offensive",
  target_num = 1,
  can_use = function(self, player)
    return player:usedSkillTimes(yingba.name, Player.HistoryPhase) == 0
  end,
  card_filter = function(self, player, to_select, selected)
    return false
  end,
  target_filter = function(self, player, to_select, selected)
    return player.id ~= to_select and Fk:currentRoom():getPlayerById(to_select).maxHp > 1
  end,
  on_use = function(self, room, effect)
    local to = effect.tos[1]
    room:changeMaxHp(to, -1)
    room:addPlayerMark(to, "@joy__yingba_pingding")
    room:changeMaxHp(effect.from, -1)
  end,
})

yingba:addEffect("targetmod", {
  name = "#joy__yingba-buff",
  bypass_distances =  function(self, player, skill, card, to)
    return player:hasSkill("joy__yingba") and to and to:getMark("@joy__yingba_pingding") > 0
  end,
})

return yingba